﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using RVBike.Properties;

namespace RVBike
{
    /// <summary>
    /// Interaction logic for SettingWindow.xaml
    /// </summary>
    public partial class SettingWindow : Window
    {
        public string SelectedLanguage { get; set; }

        public SettingWindow()
        {
            InitializeComponent();

            btn_ok.Content = MultiLanguage.Instance().Translate("apply");
            btn_cancel.Content = MultiLanguage.Instance().Translate("cancel");
            lbl_Language.Content = String.Format("{0} :", MultiLanguage.Instance().Translate("language"));

            List<string> langs = MultiLanguage.Instance().AvailableLanguages;
            
            cb_Language.Items.Clear();
            for (int i = 0 ; i < langs.Count ; ++i)
            {
                cb_Language.Items.Add(MultiLanguage.Instance().Translate(langs[i]));
                if (langs[i] == Settings.Default.Locale)
                {
                    cb_Language.SelectedIndex = i;
                    SelectedLanguage = langs[i];
                }
            }
        }

        private void OnOK(object sender, RoutedEventArgs e)
        {
            List<string> langs = MultiLanguage.Instance().AvailableLanguages;
            SelectedLanguage = langs[cb_Language.SelectedIndex];

            this.DialogResult = true;
            this.Close();
        }

        private void OnCancel(object sender, RoutedEventArgs e)
        {
            this.DialogResult = false;
            this.Close();
        }
    }
}
